﻿using System;

namespace HealthCommunity
{
	public partial class Activation : System.Web.UI.Page
	{

		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				var qqid = CommonHelper.QueryString("qqid");
				var activationcode = CommonHelper.QueryString("activationcode");

				try
				{
					var qqidProvider = new DBProvider.Providers.QQIDProvider();
					var theQQID = qqidProvider.GetQQID(qqid);

					if (theQQID != null)
					{
						if (theQQID.SubmitTime.Value.AddHours(24) > DateTime.Now)
						{
							if (theQQID.ActivationCode.Equals(activationcode))
							{
								theQQID.ActivationState = (int)DBProvider.QQActivationState.Activated;
								theQQID.ActivationTime = DateTime.Now;

								if (qqidProvider.UpdateQQID(theQQID))
								{
									//Response.Write("激活成功");
									//Response.Redirect("Register2.aspx");
									Server.Transfer("Register2.aspx", true);
								}
							}
						}
						else
						{
							Response.Write("已过期,请重新注册");
						}
					}
				}
				catch (Exception exc)
				{
					Response.Write(exc.Message);
				}
			}
		}
	}
}